package asteroids.model.programs.parsing.expressions;

import java.util.List;
import java.util.Map;

import asteroids.model.programs.parsing.types.*;

/**
 * A class of mathematical expressions.
 * A mathematical expression involves a single operator applied to only one operand.
 * 
 * @author Thijs Dieltjens - Wim Konings
 * @version 2.0
 */
public abstract class MathematicalExpr extends UnOpExpr {

	public MathematicalExpr(Expression expr, int line, int column) {
		super(expr,line,column);
	}

	@Override
	public  List<String> getTypeCheckErrors(List<String> errors, Map<String, Type> globals) {
		if (getOperand().eval(null, null).getClass() != DoubleLiteral.class){
			errors.add(getLine()+"-"+getColumn()+": No valid input for mathematical expression.");
		}
		return errors;
	}
}
